package cn.iocoder.yudao.module.wine.dal.mysql.stockinfo;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import cn.iocoder.yudao.module.wine.controller.app.stockinfo.vo.AppStockInfoListReqVO;
import cn.iocoder.yudao.module.wine.controller.app.stockinfo.vo.AppStockInfoRespVO;
import cn.iocoder.yudao.module.wine.dal.dataobject.stockinfo.StockInfoDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.wine.controller.admin.stockinfo.vo.*;

/**
 * 出入库信息 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface StockInfoMapper extends BaseMapperX<StockInfoDO> {

    default PageResult<StockInfoRespVO> selectPage(StockInfoPageReqVO reqVO) {
        return selectJoinPage(reqVO, StockInfoRespVO.class, new MPJLambdaWrapperX<StockInfoDO>()
                .eqIfPresent(StockInfoDO::getUserId, reqVO.getUserId())
                .eqIfPresent(StockInfoDO::getStoreId, reqVO.getStoreId())
                .eqIfPresent(StockInfoDO::getOperateType, reqVO.getOperateType())
                .eqIfPresent(StockInfoDO::getInfoId, reqVO.getInfoId())
                .likeIfPresent(StockInfoDO::getInfoName, reqVO.getInfoName())
                .eqIfPresent(StockInfoDO::getInfoSn, reqVO.getInfoSn())
                .eqIfPresent(StockInfoDO::getInfoNums, reqVO.getInfoNums())
                .eqIfPresent(StockInfoDO::getInfoBn, reqVO.getInfoBn())
                .eqIfPresent(StockInfoDO::getInfoDesc, reqVO.getInfoDesc())
                .eqIfPresent(StockInfoDO::getInfoStatus, reqVO.getInfoStatus())
                .eqIfPresent(StockInfoDO::getAddType, reqVO.getAddType())
                .eqIfPresent(StockInfoDO::getScanStatus, reqVO.getScanStatus())
                .eqIfPresent(StockInfoDO::getOrderId, reqVO.getOrderId())
                .betweenIfPresent(StockInfoDO::getCreateTime, reqVO.getCreateTime())
                .leftJoin(MemberUserDO.class,MemberUserDO::getId,StockInfoDO::getUserId)
                .selectAll(StockInfoDO.class)
                .selectAs(MemberUserDO::getName,StockInfoRespVO::getName)
                .orderByDesc(StockInfoDO::getId));
    }

    default List<AppStockInfoRespVO> getStockInfoList(AppStockInfoListReqVO reqVO){
        return selectJoinList(AppStockInfoRespVO.class, new MPJLambdaWrapperX<StockInfoDO>()
                .eqIfPresent(StockInfoDO::getUserId, SecurityFrameworkUtils.getLoginUserId())
                .eqIfPresent(StockInfoDO::getStoreId, reqVO.getStoreId())
                .eqIfPresent(StockInfoDO::getOperateType, reqVO.getOperateType())
                .likeIfPresent(StockInfoDO::getUsername, reqVO.getUsername())
                .likeIfPresent(StockInfoDO::getMobile, reqVO.getMobile())
                .likeIfPresent(StockInfoDO::getCompany, reqVO.getCompany())
                .eqIfPresent(StockInfoDO::getInfoId, reqVO.getInfoId())
                .likeIfPresent(StockInfoDO::getInfoName, reqVO.getInfoName())
                .eqIfPresent(StockInfoDO::getInfoSn, reqVO.getInfoSn())
                .eqIfPresent(StockInfoDO::getInfoNums, reqVO.getInfoNums())
                .eqIfPresent(StockInfoDO::getInfoBn, reqVO.getInfoBn())
                .eqIfPresent(StockInfoDO::getInfoDesc, reqVO.getInfoDesc())
                .eqIfPresent(StockInfoDO::getInfoStatus, reqVO.getInfoStatus())
                .eqIfPresent(StockInfoDO::getAddType, reqVO.getAddType())
                .eqIfPresent(StockInfoDO::getScanStatus, reqVO.getScanStatus())
                .eqIfPresent(StockInfoDO::getOrderId, reqVO.getOrderId()));
    }
}
